#pragma once
#include <map>
#include <GdiPlus.h>
using namespace Gdiplus;
using namespace std;

/// <summary>
/// Auto manage bursh (GDI+ object) resources.
/// </summary>
/// <remark>
/// None.
/// </remark>
class AFX_EXT_CLASS CBrushLib
{

public:
	CBrushLib(void);
	~CBrushLib(void);

public:
	/// The type of brush which can be managed.
	enum BRUSH_TYPE
	{
		/// solid
		BRUSH_TYPE_SOLID,
	};

public:
	/// Properties for creating brush
	typedef struct tagBRUSH_PROPERTIES
	{
		/// use this variable to find brush. 0 means unused.
		int		nFlag;	
		tagBRUSH_PROPERTIES()
		{
			nFlag = 0;
		}
	}BRUSH_PROPERTIES;

public:
	// Return the point of Brush object 
	Brush* GetBrush(BRUSH_TYPE lbStyle, COLORREF lbColor, BRUSH_PROPERTIES sProperties);
	// Release resource
	void FreeBrushes();

protected:
	// Create a Brush object
	Brush* CreateBrush(BRUSH_TYPE lbStyle, COLORREF lbColor, BRUSH_PROPERTIES sProperties);

protected:
	typedef pair<BRUSH_TYPE,COLORREF> map_Pair1;
	typedef pair<map_Pair1, int> map_Pair2;
	typedef map<map_Pair2, Brush*> map_Brushs;
	map_Brushs m_mapBrushs;
};
